//配置token验证规则

const expressJWT = require("express-jwt");
const { TOKEN_KEY } = require("./consts");

const jwtAuth = expressJWT({
    secret: TOKEN_KEY,//生成token是使用的编码字符串
    algorithms: ["HS256"],//设置jwt的算法
    credentialsRequired: false//对token请求不进行解析和抛出异常
}).unless({
    path: ["/admins/login", "/customer/login", "/customer/register", "/products/getProducts", "/order/getMessage", "/compensation/getAllCompensation"]//配置不需要经过token的url请求
})

module.exports = jwtAuth;